package com.spring.test.dao;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author wangjie
 * @Version V1.0.0
 * @Date Created in 2022/3/7 0007
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class RespBean {

    //状态码
    private int code;

    //返回的信息
    private String message;

    //返回的结果
    private Object data;
    private Map<String,Object> extend=new HashMap<String, Object>();

    public static RespBean success(){
        RespBean result = new RespBean();
        result.setCode(200);
        result.setMessage("处理成功");
        return result;
    }
    public static RespBean fail(){
        RespBean result = new RespBean();
        result.setCode(100);
        result.setMessage("处理失败");
        return result;
    }
    public static RespBean success(Object data){
        RespBean result = new RespBean();
        result.setData(data);
        result.setCode(200);
        result.setMessage("获取成功");
        return result;
    }
    public RespBean add(String key,Object value){
        this.getExtend().put(key,value);
        return this;
    }
    public Map<String, Object> getExtend() {
        return extend;
    }

    public void setExtend(Map<String, Object> extend) {
        this.extend = extend;
    }

}
